<%@ page import="javabean.Customer" %>
<%@ page import="javabean.Complaint" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: 32650
  Date: 2023-05-23
  Time: 1:50
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ include file="check.jsp" %>
<%
    Customer customer = (Customer) session.getAttribute("loginCustomer");
    List<Complaint> complaintList = (List<Complaint>) request.getAttribute("complaintList");
    List<Complaint> UnassignedComplaintList = (List<Complaint>) request.getAttribute("UnassignedComplaintList");
    if (complaintList == null && UnassignedComplaintList == null) {
        out.print("<script>alert('您还没有投诉！');window.location.href='index.jsp'</script>");
    }
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <meta
            name="viewport"
            content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
    />
    <meta http-equiv="X-UA-Compatible" content="ie=edge"/>
    <link href="css/Bar.css" rel="stylesheet">
    <link href="css/MyComplaint.css" rel="stylesheet">
    <title>移动网上营业厅</title>
</head>
<body>
<div class="header">
    <h2>移动网上营业厅</h2>
</div>
<div class="content">
    <div class="left">
        <ul>
            <li><a href="Personal_Info.jsp">个人信息</a></li>
            <li><a href="MyPackage">我的套餐</a></li>
            <li><a href="Balance.jsp">查询余额</a></li>
            <li><a href="MyBill.jsp">查询账单</a></li>
            <li><a href="Subpackage">套餐订购</a></li>
            <li><a href="Recharge.jsp">充值缴费</a></li>
            <li><a href="MyOrder.jsp">我的订单</a></li>
            <li><a href="MyComplaint">我的投诉</a></li>
            <li><a href="MyMaintenance">我的报修</a></li>
            <li><a href="Account_cancellation.jsp">账号注销</a></li>
            <li><a href="Logout">退出登录</a></li>
        </ul>
    </div>
    <div class="right">
        <div class="container">
            <%
                if (UnassignedComplaintList != null && UnassignedComplaintList.size() > 0) {
            %>
            <h2>待处理投诉</h2>
            <table>
                <tr>
                    <th>投诉号</th>
                    <th>订单号</th>
                    <th>投诉日期</th>
                    <th>投诉内容</th>
                </tr>
                <%
                    for (Complaint complaint : UnassignedComplaintList) {
                %>
                <tr>
                    <td><%=complaint.getComplaintID()%>
                    </td>
                    <td><%=complaint.getOrderID()%>
                    </td>
                    <td><%=complaint.getComplaintDate()%>
                    </td>
                    <td><%=complaint.getComplaintDescription()%>
                    </td>
                </tr>
                <%
                    }
                %>
            </table>
            <%
                }
            %>
            <%
                if (complaintList != null && complaintList.size() > 0) {
            %>
            <h2>已处理投诉</h2>
            <table>
                <tr>
                    <th>投诉号</th>
                    <th>订单号</th>
                    <th>处理人员</th>
                    <th>投诉日期</th>
                    <th>投诉状态</th>
                    <th>投诉内容</th>
                    <th>用户评价</th>
                </tr>
                <%
                    for (Complaint complaint : complaintList) {
                %>
                <tr>
                    <td><%=complaint.getComplaintID()%>
                    </td>
                    <td><%=complaint.getOrderID()%>
                    </td>
                    <%
                        if (complaint.getStaffID() == null) {
                            out.print("<td>暂无</td>");
                        } else {
                            out.print("<td>" + complaint.getStaffID() + "</td>");
                        }
                    %>
                    <td><%=complaint.getComplaintDate()%>
                    </td>
                    <%
                        //TODO 该解决方案不够优雅，应该从DAO层解决
                        if (complaint.getComplaintStatus() == null) {
                            out.print("<td>待处理</td>");
                        } else {
                            out.print("<td>" + complaint.getComplaintStatus() + "</td>");
                        }
                    %>
                    <td><%=complaint.getComplaintDescription()%>
                    </td>
                    <%
                        if (complaint.getEvaluation() == null) {
                    %>
                    <td><a href="Evaluation.jsp?op=1&id=<%=complaint.getComplaintID()%>">评价</a></td>
                    <%
                        } else {
                            out.print(" <td>" + complaint.getEvaluation() + "</td>");
                        }
                    %>
                </tr>
                <%
                        }
                    }
                %>
            </table>
            <a href="Complaint.jsp">发起投诉</a>
        </div>
    </div>
</div>
</body>
</html>
